package com.gress.shop.enums;

import org.apache.commons.lang.StringUtils;

import java.io.Serializable;

/**
 * Created xiongwen with 2018/3/6 14:22
 * Description:
 */
public enum MenuEnum implements Serializable {
    /**
     * 功能项
     */
    PERMISSION("功能项", "J_menuItem"),

    /**
     * 外部跳转功能项
     */
    BLANK("打开新页面", "_blank"),

    /**
     * 菜单项
     */
    MENU("菜单", "menu"),
    ;


    private String name;

    private String menuCode;

    public String getName() {
        return name;
    }

    public String getMenuCode() {
        return menuCode;
    }

    MenuEnum(String name, String menuCode) {
        this.name = name;
        this.menuCode = menuCode;
    }

    /**
     * 拿取两个 功能
     */
    public static MenuEnum[] getFunctionMenuEnum() {
        MenuEnum[] x = {BLANK, PERMISSION};
        return x;
    }

    /***
     *  校验合法性
     * */
    public static boolean checkLawful(String menuCode) {
        for (MenuEnum element : values()) {
            if (StringUtils.equals(menuCode, element.menuCode)) {
                return true;
            }
        }
        return false;
    }

}
